HAL SAI types migration ¶
This section provides information about the HAL SAI types migration.
HAL SAI callback ID type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_SAI_RX_COMPLETE_CB_ID,
HAL_SAI_RX_HALFCOMPLETE_CB_ID,
HAL_SAI_TX_COMPLETE_CB_ID,
HAL_SAI_TX_HALFCOMPLETE_CB_ID,
HAL_SAI_ERROR_CB_ID,
HAL_SAI_MSPINIT_CB_ID,
HAL_SAI_MSPDEINIT_CB_ID,
} HAL_SAI_CallbackIDTypeDef;
|
|
Related concepts:
HAL SAI state type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
HAL_SAI_STATE_RESET,
HAL_SAI_STATE_READY,
HAL_SAI_STATE_BUSY,
HAL_SAI_STATE_BUSY_TX,
HAL_SAI_STATE_BUSY_RX,
HAL_SAI_STATE_TIMEOUT,
HAL_SAI_STATE_ERROR,
} HAL_SAI_StateTypeDef;
|
typedef enum
{
HAL_SAI_STATE_RESET,
HAL_SAI_STATE_INIT,
HAL_SAI_STATE_IDLE,
HAL_SAI_STATE_TX_ACTIVE,
HAL_SAI_STATE_RX_ACTIVE,
HAL_SAI_STATE_TX_PAUSED,
HAL_SAI_STATE_RX_PAUSED,
HAL_SAI_STATE_ABORT,
} hal_sai_state_t;
|
Related concepts:
HAL SAIEx PDM microphone delay type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t MicPair;
uint32_t LeftDelay;
uint32_t RightDelay;
} SAIEx_PdmMicDelayParamTypeDef;
|
typedef struct
{
uint32_t pdm_mic_pairs_nbr;
uint32_t pdm_left_delay;
uint32_t pdm_right_delay;
} hal_sai_pdm_mic_delay_t;
|
Related concept: Replaced TypeDef suffix with _t in type names
HAL SAI handle type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef SAI_HandleTypeDef;
|
typedef hal_sai_handle_t;
|
Related concepts:
HAL SAI slot initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t FirstBitOffset;
uint32_t SlotSize;
uint32_t SlotNumber;
uint32_t SlotActive;
} SAI_SlotInitTypeDef;
|
typedef struct
{
uint32_t slot_first_bit_offset;
hal_sai_slot_size_t slot_size;
uint32_t slot_number;
uint32_t slot_active;
} hal_sai_slot_t;
|
Related concept: Replaced TypeDef suffix with _t in type names
HAL SAI frame initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t FrameLength;
uint32_t ActiveFrameLength;
uint32_t FSDefinition;
uint32_t FSPolarity;
uint32_t FSOffset;
} SAI_FrameInitTypeDef;
|
typedef struct
{
uint32_t frame_length;
uint32_t active_frame_length;
hal_sai_fs_definition_t fs_definition;
hal_sai_fs_polarity_t fs_polarity;
hal_sai_fs_offset_t fs_offset;
} hal_sai_frame_t;
|
Related concept: Replaced TypeDef suffix with _t in type names
HAL SAI initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
|
In HAL1, the configuration parameters such as
typedef struct
{
uint32_t AudioMode;
uint32_t NoDivider;
uint32_t AudioFrequency;
uint32_t Mckdiv;
uint32_t MckOverSampling;
uint32_t Protocol;
uint32_t DataSize;
uint32_t FirstBit;
uint32_t ClockStrobing;
uint32_t Synchro;
uint32_t SynchroExt;
uint32_t MckOutput;
uint32_t OutputDrive;
uint32_t FIFOThreshold;
uint32_t MonoStereoMode;
uint32_t CompandingMode;
uint32_t TriState;
SAI_PdmInitTypeDef PdmInit;
} SAI_InitTypeDef;
/*
HAL1 to HAL2:
SAI_FrameInitTypeDef FrameInit corresponds to hal_sai_frame_t frame.
SAI_SlotInitTypeDef SlotInit corresponds to hal_sai_slot_t slot.
*/
typedef struct __SAI_HandleTypeDef
{
...
SAI_FrameInitTypeDef FrameInit;
SAI_SlotInitTypeDef SlotInit;
...
} SAI_HandleTypeDef;
|
In HAL2, all these parameters have been removed from
typedef struct
{
hal_sai_mode_t mode;
hal_sai_master_divider_t divider;
hal_sai_audio_frequency_t audio_frequency;
uint32_t mclk_div;
hal_sai_mclk_oversampling_t mclk_oversampling;
hal_sai_protocol_t protocol;
hal_sai_data_size_t data_size;
hal_sai_bit_order_t bit_order;
hal_sai_clock_strobing_edge_t clock_strobing_edge;
hal_sai_frame_t frame;
hal_sai_slot_t slot;
} hal_sai_config_t;
hal_status_t HAL_SAI_SetSync(hal_sai_handle_t *hsai,
hal_sai_sync_t sync);
hal_sai_sync_output_t HAL_SAI_GetSyncOutput(const hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_SetSyncOutput(hal_sai_handle_t *hsai,
hal_sai_sync_output_t sync_output);
hal_sai_sync_output_t HAL_SAI_GetSyncOutput(const hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_EnableMclkOutput(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_DisableMclkOutput(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_EnableOutputDrive(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_DisableOutputDrive(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_SetFifoThreshold(hal_sai_handle_t *hsai,
hal_sai_fifo_threshold_t fifo_threshold);
hal_sai_fifo_threshold_t HAL_SAI_GetFifoThreshold(const hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_EnableMonoMode(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_DisableMonoMode(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_SetCompanding(hal_sai_handle_t *hsai,
hal_sai_companding_t companding);
hal_sai_companding_t HAL_SAI_GetCompanding(const hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_EnableTristateSDOutput(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_DisableTristateSDOutput(hal_sai_handle_t *hsai);
hal_status_t HAL_SAI_EnablePdm(const hal_sai_handle_t *hsai,
uint32_t pdm_mic_pairs_nbr, hal_sai_pdm_clock_t clock);
hal_status_t HAL_SAI_DisablePdm(const hal_sai_handle_t *hsai);
|
Note
In HAL1, the
SAI_SlotInitTypeDef
and
SAI_FrameInitTypeDef
are exposed directly through the handle, and the user has to fill them directly within the handle.
In HAL2, they are exposed to the user via
hal_sai_config_t
structure as
slot
and
frame
members.
Related concepts:
HAL SAI PDM initialization type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
FunctionalState Activation;
uint32_t MicPairsNbr;
uint32_t ClockEnable;
} SAI_PdmInitTypeDef;
|
In HAL2, the
|
Related concept: Replaced TypeDef suffix with _t in type names